package com.ruoyi.stock2.service.impl;

import com.ruoyi.stock2.domain.TRADEDATA;

import java.lang.ref.WeakReference;
import java.util.List;

public class WeakReferenceTool implements Runnable {
    /**
     * When an object implementing interface <code>Runnable</code> is used
     * to create a thread, starting the thread causes the object's
     * <code>run</code> method to be called in that separately executing
     * thread.
     * <p>
     * The general contract of the method <code>run</code> is that it may
     * take any action whatsoever.
     *
     * @see Thread#run()
     */
    private List listtrades;

    public void setListtrades(List listtrades) {
        this.listtrades = listtrades;
    }

    @Override
    public void run() {
        if (listtrades != null) {
            WeakReference<List<TRADEDATA>> gc1 = new WeakReference<List<TRADEDATA>>(listtrades);
            int ii = 1;
            listtrades = null;
            while (gc1.get() != null && ii != 2) {
                System.gc();
                ii++;
            }
        }
    }
}
